home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / game / shoot / ADoomPPC_src.lha / ADoomPPC_src / p_mobj.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  8.9 KB  |  299 lines

  1. // Emacs style mode select   -*- C++ -*- 
  2. //-----------------------------------------------------------------------------
  3. //
  4. // $Id:$
  5. //
  6. // Copyright (C) 1993-1996 by id Software, Inc.
  7. //
  8. // This source is available for distribution and/or modification
  9. // only under the terms of the DOOM Source Code License as
  10. // published by id Software. All rights reserved.
  11. //
  12. // The source is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
  15. // for more details.
  16. //
  17. // DESCRIPTION:
  18. //    Map Objects, MObj, definition and handling.
  19. //
  20. //-----------------------------------------------------------------------------
  21.  
  22.  
  23. #ifndef __P_MOBJ__
  24. #define __P_MOBJ__
  25.  
  26. // Basics.
  27. #include "tables.h"
  28. #include "m_fixed.h"
  29.  
  30. // We need the thinker_t stuff.
  31. #include "d_think.h"
  32.  
  33. // We need the WAD data structure for Map things,
  34. // from the THINGS lump.
  35. #include "doomdata.h"
  36.  
  37. // States are tied to finite states are
  38. //  tied to animation frames.
  39. // Needs precompiled tables/data structures.
  40. #include "info.h"
  41.  
  42.  
  43.  
  44. #ifdef __GNUG__
  45. #pragma interface
  46. #endif
  47.  
  48. #ifdef __SASC
  49. #pragma options align=mac68k
  50. #endif
  51.  
  52.  
  53. //
  54. // NOTES: mobj_t
  55. //
  56. // mobj_ts are used to tell the refresh where to draw an image,
  57. // tell the world simulation when objects are contacted,
  58. // and tell the sound driver how to position a sound.
  59. //
  60. // The refresh uses the next and prev links to follow
  61. // lists of things in sectors as they are being drawn.
  62. // The sprite, frame, and angle elements determine which patch_t
  63. // is used to draw the sprite if it is visible.
  64. // The sprite and frame values are allmost allways set
  65. // from state_t structures.
  66. // The statescr.exe utility generates the states.h and states.c
  67. // files that contain the sprite/frame numbers from the
  68. // statescr.txt source file.
  69. // The xyz origin point represents a point at the bottom middle
  70. // of the sprite (between the feet of a biped).
  71. // This is the default origin position for patch_ts grabbed
  72. // with lumpy.exe.
  73. // A walking creature will have its z equal to the floor
  74. // it is standing on.
  75. //
  76. // The sound code uses the x,y, and subsector fields
  77. // to do stereo positioning of any sound effited by the mobj_t.
  78. //
  79. // The play simulation uses the blocklinks, x,y,z, radius, height
  80. // to determine when mobj_ts are touching each other,
  81. // touching lines in the map, or hit by trace lines (gunshots,
  82. // lines of sight, etc).
  83. // The mobj_t->flags element has various bit flags
  84. // used by the simulation.
  85. //
  86. // Every mobj_t is linked into a single sector
  87. // based on its origin coordinates.
  88. // The subsector_t is found with R_PointInSubsector(x,y),
  89. // and the sector_t can be found with subsector->sector.
  90. // The sector links are only used by the rendering code,
  91. // the play simulation does not care about them at all.
  92. //
  93. // Any mobj_t that needs to be acted upon by something else
  94. // in the play world (block movement, be shot, etc) will also
  95. // need to be linked into the blockmap.
  96. // If the thing has the MF_NOBLOCK flag set, it will not use
  97. // the block links. It can still interact with other things,
  98. // but only as the instigator (missiles will run into other
  99. // things, but nothing can run into a missile).
  100. // Each block in the grid is 128*128 units, and knows about
  101. // every line_t that it contains a piece of, and every
  102. // interactable mobj_t that has its origin contained.  
  103. //
  104. // A valid mobj_t is a mobj_t that has the proper subsector_t
  105. // filled in for its xy coordinates and is linked into the
  106. // sector from which the subsector was made, or has the
  107. // MF_NOSECTOR flag set (the subsector_t needs to be valid
  108. // even if MF_NOSECTOR is set), and is linked into a blockmap
  109. // block or has the MF_NOBLOCKMAP flag set.
  110. // Links should only be modified by the P_[Un]SetThingPosition()
  111. // functions.
  112. // Do not change the MF_NO? flags while a thing is valid.
  113. //
  114. // Any questions?
  115. //
  116.  
  117. //
  118. // Misc. mobj flags
  119. //
  120. typedef enum
  121. {
  122.     // Call P_SpecialThing when touched.
  123.      MF_SPECIAL        = 1,
  124.     // Blocks.
  125.      MF_SOLID        = 2,
  126.     // Can be hit.
  127.      MF_SHOOTABLE    = 4,
  128.     // Don't use the sector links (invisible but touchable).
  129.      MF_NOSECTOR        = 8,
  130.     // Don't use the blocklinks (inert but displayable)
  131.      MF_NOBLOCKMAP    = 16,                    
  132.  
  133.     // Not to be activated by sound, deaf monster.
  134.      MF_AMBUSH        = 32,
  135.     // Will try to attack right back.
  136.      MF_JUSTHIT        = 64,
  137.     // Will take at least one step before attacking.
  138.      MF_JUSTATTACKED    = 128,
  139.     // On level spawning (initial position),
  140.     //  hang from ceiling instead of stand on floor.
  141.      MF_SPAWNCEILING    = 256,
  142.     // Don't apply gravity (every tic),
  143.     //  that is, object will float, keeping current height
  144.     //  or changing it actively.
  145.      MF_NOGRAVITY    = 512,
  146.  
  147.     // Movement flags.
  148.     // This allows jumps from high places.
  149.      MF_DROPOFF        = 0x400,
  150.     // For players, will pick up items.
  151.      MF_PICKUP        = 0x800,
  152.     // Player cheat. ???
  153.      MF_NOCLIP        = 0x1000,
  154.     // Player: keep info about sliding along walls.
  155.      MF_SLIDE        = 0x2000,
  156.     // Allow moves to any height, no gravity.
  157.     // For active floaters, e.g. cacodemons, pain elementals.
  158.      MF_FLOAT        = 0x4000,
  159.     // Don't cross lines
  160.     //   ??? or look at heights on teleport.
  161.      MF_TELEPORT        = 0x8000,
  162.     // Don't hit same species, explode on block.
  163.     // Player missiles as well as fireballs of various kinds.
  164.      MF_MISSILE        = 0x10000,    
  165.     // Dropped by a demon, not level spawned.
  166.     // E.g. ammo clips dropped by dying former humans.
  167.      MF_DROPPED        = 0x20000,
  168.     // Use fuzzy draw (shadow demons or spectres),
  169.     //  temporary player invisibility powerup.
  170.      MF_SHADOW        = 0x40000,
  171.     // Flag: don't bleed when shot (use puff),
  172.     //  barrels and shootable furniture shall not bleed.
  173.      MF_NOBLOOD        = 0x80000,
  174.     // Don't stop moving halfway off a step,
  175.     //  that is, have dead bodies slide down all the way.
  176.      MF_CORPSE        = 0x100000,
  177.     // Floating to a height for a move, ???
  178.     //  don't auto float to target's height.
  179.      MF_INFLOAT        = 0x200000,
  180.  
  181.     // On kill, count this enemy object
  182.     //  towards intermission kill total.
  183.     // Happy gathering.
  184.      MF_COUNTKILL    = 0x400000,
  185.     
  186.     // On picking up, count this item object
  187.     //  towards intermission item total.
  188.      MF_COUNTITEM    = 0x800000,
  189.  
  190.     // Special handling: skull in flight.
  191.     // Neither a cacodemon nor a missile.
  192.      MF_SKULLFLY        = 0x1000000,
  193.  
  194.     // Don't spawn this object
  195.     //  in death match mode (e.g. key cards).
  196.      MF_NOTDMATCH        = 0x2000000,
  197.  
  198.     // Player sprites in multiplayer modes are modified
  199.     //  using an internal color lookup table for re-indexing.
  200.     // If 0x4 0x8 or 0xc,
  201.     //  use a translation table for player colormaps
  202.      MF_TRANSLATION      = 0xc000000,
  203.     // Hmm ???.
  204.      MF_TRANSSHIFT    = 26
  205. }  mobjflag_t;
  206.  
  207. // Map Object definition.
  208. typedef struct mobj_s
  209. {
  210.     // List: thinker links.
  211.     thinker_t         thinker;
  212.  
  213.     // Info for drawing: position.
  214.     fixed_t         x;
  215.     fixed_t         y;
  216.     fixed_t         z;
  217.  
  218.     // More list: links in sector (if needed)
  219.     struct mobj_s  *    snext;
  220.     struct mobj_s  *    sprev;
  221.  
  222.     //More drawing info: to determine current sprite.
  223.     angle_t         angle;    // orientation
  224.     spritenum_t         sprite;    // used to find patch_t and flip value
  225.     int             frame;    // might be ORed with FF_FULLBRIGHT
  226.  
  227.     // Interaction info, by BLOCKMAP.
  228.     // Links in blocks (if needed).
  229.     struct mobj_s  *    bnext;
  230.     struct mobj_s  *    bprev;
  231.     
  232.     struct subsector_s  *    subsector;
  233.  
  234.     // The closest interval over all contacted Sectors.
  235.     fixed_t         floorz;
  236.     fixed_t         ceilingz;
  237.  
  238.     // For movement checking.
  239.     fixed_t         radius;
  240.     fixed_t         height;    
  241.  
  242.     // Momentums, used to update position.
  243.     fixed_t         momx;
  244.     fixed_t         momy;
  245.     fixed_t         momz;
  246.  
  247.     // If == validcount, already checked.
  248.     int             validcount;
  249.  
  250.     mobjtype_t         type;
  251.     mobjinfo_t  *        info;    // &mobjinfo[mobj->type]
  252.     
  253.     int             tics;    // state tic counter
  254.     state_t  *        state;
  255.     int             flags;
  256.     int             health;
  257.  
  258.     // Movement direction, movement generation (zig-zagging).
  259.     int             movedir;    // 0-7
  260.     int             movecount;    // when 0, select a new dir
  261.  
  262.     // Thing being chased/attacked (or NULL),
  263.     // also the originator for missiles.
  264.     struct mobj_s  *    target;
  265.  
  266.     // Reaction time: if non 0, don't attack yet.
  267.     // Used by player to freeze a bit after teleporting.
  268.     int             reactiontime;   
  269.  
  270.     // If >0, the target will be chased
  271.     // no matter what (even if shot)
  272.     int             threshold;
  273.  
  274.     // Additional info record for player avatars only.
  275.     // Only valid if type == MT_PLAYER
  276.     struct player_s  *    player;
  277.  
  278.     // Player number last looked for.
  279.     int             lastlook;    
  280.  
  281.     // For nightmare respawn.
  282.     mapthing_t         spawnpoint;    
  283.  
  284.     // Thing being chased/attacked for tracers.
  285.     struct mobj_s  *    tracer;    
  286.     
  287. }  mobj_t;
  288.  
  289. #ifdef __SASC
  290. #pragma options align=power
  291. #endif
  292.  
  293. #endif
  294. //-----------------------------------------------------------------------------
  295. //
  296. // $Log:$
  297. //
  298. //-----------------------------------------------------------------------------
  299.